package com.cx.lambda;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;

/**
 * @author zhangshuai
 * @version V1.0
 * @Project Java2_26
 * @Package com.cx.lambda
 * @Description:
 * @Date 2025/5/22 15:28
 */

public class StreamTest {
    //Stream 与集合类似，
    // 但集合中保存的是数据，
    // 而Stream中保存的是对集合或者数组的数据的操作。所以 **Stream是对数据集操作的集合**

    public static void main(String[] args) throws IOException {
        //创建流 stream()
        String[] strings = {"aaaa", "bbbb", "cccc"};
        //从集合创建stream流
        Stream<String> stream = Arrays.asList(strings).stream();//从集合创建stream流
        System.out.println(stream); //从数组创建stream流
        Stream<String> stream1 = Arrays.stream(strings);
        System.out.println(stream1);
        Stream<String> appla = Stream.of("appla", "banana", "orange");
        System.out.println(appla);

       /* Files.lines(Paths.get("file.txt")).forEach(System.out::println);*/
    }
    }